# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>
# Contributor: Simon 'ALSimon' Gilliot <simon@gilliot.fr>
# Contributor: Olivier Biesmans <olivier at biesmans dot fr>
# Contributor: Dobroslaw Kijowski

pkgname=mitmproxy
pkgver=9.0.1
pkgrel=2
pkgdesc='SSL-capable man-in-the-middle HTTP proxy'
arch=('any')
url='https://mitmproxy.org'
license=('MIT')
depends=('python-asgiref' 'python-blinker' 'python-brotli' 'python-certifi' 'python-cryptography'
         'python-flask' 'python-h11' 'python-h2' 'python-hyperframe' 'python-kaitaistruct'
         'python-ldap3' 'python-mitmproxy-wireguard' 'python-msgpack' 'python-passlib' 'python-protobuf'
         'python-pyopenssl' 'python-pyparsing' 'python-pyperclip' 'python-ruamel-yaml' 'python-setuptools'
         'python-sortedcontainers' 'python-tornado' 'python-urwid' 'python-wsproto' 'python-publicsuffix2'
         'python-zstandard')
checkdepends=('python-asynctest' 'python-parver' 'python-pytest-runner' 'python-pytest-asyncio'
              'python-requests' 'python-hypothesis')
provides=('pathod')
conflicts=('pathod')
replaces=('pathod')
source=("https://github.com/mitmproxy/mitmproxy/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('601d9171f48d93fbc6f002a1dc243c2f358186059e491490ffe5ab7be797e8e622fdb5a9e2fdab10fac7350057f9e9491952527d600477c841c9b5102a045bc1')

prepare() {
  cd $pkgname-$pkgver

  # Let's remove all the upper bounds
  sed -e 's/, *<[0-9=.]*//' \
      -i setup.py
}

build() {
  cd $pkgname-$pkgver
  python setup.py build
}

check() {
  cd $pkgname-$pkgver
  python setup.py pytest --addopts "--deselect test/mitmproxy/test_version.py::test_get_version"
}

package() {
  cd $pkgname-$pkgver
  python setup.py install --root="$pkgdir" -O1

  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
